import React from 'react'
// ===================================================================== Temp
import FormModal from '#cpt/temp/FormModal'
// ===================================================================== global declare
// ===================================================================== private
const SelectPriceModal = window.$Lazy.state(()=>import('./select-price-modal'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		selectedKeys:[],
		selectedRows: [],
		// 提交表单列表
		formData : [
			{ label: '物价项目名称',		name: 'item_name', 			half:true, required:true, p:'请选择物价项目名称', onClick:()=>{
				this.priceModal.open()
			} },
			{ label: '物价项目代码',  	name: 'price_code', 		half:true, disabled:true, required:true },
			{ label: '标准价格',  		name: 'item_price', 		half:true, disabled:true, required:true },
			{ label: '排序',			name: 'sort', 	half:true, type:'number' },
		]
	}
	
	model = {}
	
	open = kind_id => {
		this.modal.open({ formRef: this.formRef })
		this.submit = { kind_id }
	}
	
	render(){
		return (
			<>
				{ /* 添加物价 */ }
				{ FormModal.call(this,{ title: '添加物价', labelWidth:'s8', width:750, api:'kind-rel-price/add', 
					getSubmit:()=> ({ item_id:this.item_id })
				}) }
				{/* 选择物价 */}
				<SelectPriceModal onRef={ ref => this.priceModal = ref } onRefresh={rows=>{
					this.formRef.setValue({...rows, item_price: rows.price })
					this.item_id = rows.uuid
				}} />
			 </>
		)
	}
}

export default Index